package com.easylinkin.linkappapi.tenant.constant;


import java.util.HashMap;
import java.util.Map;

/**
 * 项目状态枚举类
 */
public enum ProjectStatusEnum {

    PENDING(1, "待建设"),
    IN_PROGRESS(2, "建设中"),
    COMPLETED(3, "已完工"),
    SUSPENDED(4, "停工中");

    private final Integer code;
    private final String description;

    ProjectStatusEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    private static final Map<Integer, String> codeToDescriptionMap = new HashMap<>();
    private static final Map<String, Integer> descriptionToCodeMap = new HashMap<>();

    static {
        for (ProjectStatusEnum status : ProjectStatusEnum.values()) {
            codeToDescriptionMap.put(status.getCode(), status.getDescription());
            descriptionToCodeMap.put(status.getDescription(), status.getCode());
        }
    }

    /**
     * 根据状态码获取描述
     *
     * @param code 状态码
     * @return 描述信息
     */
    public static String getDescriptionByCode(Integer code) {
        return codeToDescriptionMap.getOrDefault(code, "未知状态");
    }

    /**
     * 根据描述获取状态码
     *
     * @param description 描述信息
     * @return 状态码
     */
    public static Integer getCodeByDescription(String description) {
        return descriptionToCodeMap.getOrDefault(description, -1);
    }
}
